//
//  ViewController.m
//  ControllerAnimationDemo
//
//  Created by HuaYingJiTuan on 15/12/16.
//  Copyright © 2015年 HuaYingJiTuan. All rights reserved.
//

#import "ViewController.h"
#import "MyViewController.h"
#import "PushAnimation.h"
#import "PopViewController.h"
@interface ViewController ()<UINavigationControllerDelegate>
@property (strong, nonatomic) PushAnimation *pushAnimation;
@property (strong, nonatomic) PopViewController *popAnimation;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.navigationController.delegate = self;
    self.popAnimation = [[PopViewController alloc]init];
    self.pushAnimation = [[PushAnimation alloc]init];
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    MyViewController *vc = [[MyViewController alloc]init];
    [self.navigationController pushViewController:vc animated:YES];
}
- (nullable id <UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController
                                            animationControllerForOperation:(UINavigationControllerOperation)operation
                                                         fromViewController:(UIViewController *)fromVC
                                                           toViewController:(UIViewController *)toVC  NS_AVAILABLE_IOS(7_0){
    if (operation == UINavigationControllerOperationPush){
        return self.pushAnimation;
    }else{
        return self.popAnimation;
    }
}
@end
